<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html style="overflow: hidden;">
	<head>
		<title>${lotter.name }</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >  
		<style type="text/css">
			.btn2{background: none;border: 0;color: #009ac3;font-size: 15px;padding:3px 0px;margin-right:10px; border-radius:5px;}
			/**.btn2{background: none;border: 0;color: #fff;font-size: 15px;padding:3px 5px;border-radius:5px;}*/
			.btn3{border:0px;border-radius:50px;padding:2px;width:26px;height:26px;color: white;}
			.qiu0{background: #D8D21C;}
			.qiu1{background: #D8D21C;}
			.qiu2{background: #3273F9;}
			.qiu3{background: #515567;}
			.qiu4{background: #E6962D;}
			.qiu5{background: #0EC2C4;}
			.qiu6{background: #2D35D0;}
			.qiu7{background: #AEAFC5;}
			.qiu8{background: #E63131;}
			.qiu9{background: #7C1F1F;}
			.qiu10{background: #2DCC21;}
			.table1{margin-top: 5px;}
			.table1 tr td{height: 30px;padding:0 5px;font-size: 14px;}
			.ctr{color: ;font-weight: bold;}
			.xiazhu .title{background:#EFEFEF;padding: 8px;border-bottom: 1px solid silver; }
			.xiazhu .col-xs-6,.xiazhu .myfl{border: 1px solid #ECECEC ;padding: 5px;padding: 13px 0px;}
			.xiazhu .col-xs-6 button{margin-right: 20px;}
			.xiazhu .row{margin: 0px;}
			.xiazhu input{display:none;border:1px solid red;}
			.xiazhu span{font-weight: bold;color: gray;display: inline-block;width: 40px;}
			.xiazhu .act{background: url("/cp/img/actbg.png");background-size: 20px 20px;background-repeat: no-repeat;}
			/* .xiazhu .act *{color: white;} */
			
			.zdsd *{font-size: 14px;}
			.hemei input{text-align: center;}
			
			*{font-size: 14px;}
			.wf a{background: #EFEFEF;color:black; width: 98%;text-align: center;padding:5px;display: block; display: -moz-box;border: 1px solid white;font-size: 12px;cursor: pointer;}
			.wf .acti{background: #02AECB;color: white;}
			.wfdiv:after {
                content: ".";
                display: block;
                height: 0;
                visibility: hidden;
                clear: both;
            }
            .clearfix:after {
                content: ".";
                display: block;
                height: 0;
                visibility: hidden;
                clear: both;
            }
			.nav a{color:white;}
			
			.item .important{color:red;font-weight :bold;}
			.item .nickname{color:#099afe}
			.item,.item *{font-size:12px;}
			.item{padding-left:30px;}
			
			.xiazhu{-webkit-overflow-scrolling: touch;}
		</style>
	</head>
	<body style="height: 100%">
		<span id="id" class="hidden">${lotter.id }</span>
		<span id="cplay1" class="hidden">${keyChinese }</span>
		<span id="cname1" class="hidden">${lotter.name }</span>
		<span id="orderid" class="hidden"></span>
		<span id="cname" class="hidden">${lotter.cname }</span>
		<span class="timespace hidden">${lotter.timespace }</span>
		<span id="lasttime" class="lasttime hidden">${lotter.lottertime }</span>
		<span id="cplay" class="hidden">${key}</span>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4" style="position: fixed;top: 0;z-index: 10;background: white;">
			<div class="row" style="text-align:center;">
				<div style="color: white;background:rgb(236,74,19);height:50px;font-weight: bold;font-size: 16px;text-align: center;margin-top: 0px;padding-top: 6px;">${lotter.name }</div>
				<div class='font12	' style="margin-top:-20px;color:yellow;">下注总额：89798</div>
				<a href="<%=basePath %>gc.do" class="glyphicon glyphicon-chevron-left fl" style="color: white;margin-top: -32px;margin-left: 10px;"></a>
				<a style="color: white;margin-top: -30px;" class="fr user">
					<span style="position: fixed;top:10px;right:35px;font-size: 12px;">余额</span>
					<span style="position: fixed;top:25px;right:35px;font-size: 12px;">￥${user.balance }</span>
					<i class="glyphicon glyphicon-menu-hamburger" style="font-size:20px;margin-top: -3px;margin-right: 10px;"></i>
				</a>
				<ul class="nav hidden" style="position: fixed;top:50px;left:auto;right:0px;width:100px;text-align: center;z-index:100;background: RGBA(250,85,50,0.8) ;border-radius:0; ">
					<li><a href="/order/myOrders.do?key=all">下注记录</a></li>
					<li><a href="/dd.do">开奖记录</a></li>
					<li><a onclick="help('${lotter.cname}','${lotter.name }')">购彩助手</a></li>
					<li><a href="/dd.do">我的地盘</a></li>
					<li><a href="/exit.do">退出登录</a></li>
				</ul>
			</div>
			<table class="row table1" style="overflow: hidden;">
				<tr>
					<td class="">
						<span style="font-size: 14px;" class="period fl">${lotter.period }</span><span class="fl">　期：</span><span class="lotternumber">${lotter.lotternumber }</span>
					</td>
				</tr>
				<tr>
					<td>
						<span style="font-size: 14px;" class="xiaqi">${lotter.period+1 }</span>　期：距封盘 <span id="djs" style="font-size: 14px;font-weight: bold;"></span>
					</td>
				</tr>
				<tr>
					<td style="height: 20px;line-height: 20px;">
						<div title="1463" class="kd-marquee kd-container" >
							<div id="test1" class="inner" >
								<nobr>
									<span class="item">用户<span class="nickname">黎志**3</span> 第8名单 下注 <span class="important">￥750</span></span>
									<span class="item">用户<span class="nickname">张*先</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">吴*先</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">刘*q</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">鲁*先</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">许*芸</span> 亚军6 下注 <span class="important">￥340</span></span>
									<span class="item">用户<span class="nickname">建**8</span> 第8名2 下注 <span class="important">￥990</span></span>
									<span class="item">用户<span class="nickname">孙绍**5</span> 第5名1 下注 <span class="important">￥290</span></span>
									<span class="item">用户<span class="nickname">马**</span> 第4名7 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">黄*班</span> 第4名8 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">**谬</span> 第4名9 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">简**</span> 第4名10 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">黎志**3</span> 第8名单 下注 <span class="important">￥750</span></span>
									<span class="item">用户<span class="nickname">王*光</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">简*辉</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">朱*生</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">李*瑶</span> **** 下注 <span class="important">￥****</span></span>
									<span class="item">用户<span class="nickname">许*芸</span> 亚军6 下注 <span class="important">￥340</span></span>
									<span class="item">用户<span class="nickname">建**8</span> 第8名2 下注 <span class="important">￥990</span></span>
									<span class="item">用户<span class="nickname">孙绍**5</span> 第5名1 下注 <span class="important">￥290</span></span>
									<span class="item">用户<span class="nickname">张*浩</span> 第4名7 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">王*虎</span> 第4名8 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">杨*深</span> 第4名9 下注 <span class="important">￥7</span></span>
									<span class="item">用户<span class="nickname">黄*彬</span> 第4名10 下注 <span class="important">￥7</span></span>
								</nobr>
							</div>
						</div>
					</td>
				</tr>
			</table>
		</div>
		<div class="class-div-mainDiv clearfix col-xs-12 col-sm-4 col-sm-offset-4"style="padding: 0px;padding-bottom: 10px; margin-top: 132px; overflow: scroll;border-top:1px solid #EFEFEF;">
			<div class="col-xs-3  col-sm-1" style="position: fixed;top: 131px;padding:0;">
				${str }
			</div>
			<div class="col-xs-9 col-xs-offset-3 xiazhu text-center col-sm-9 col-sm-offset-3" style="padding: 0px;">
				<!-- 下注区 -->
					${xiazhuqu }
					
				<!-- <a name='gyhz'></a>	
				<div class="gyhz">
					<div class='title'>冠亚和值</div>
					<div class='col-xs-6'>
						<button class='btn3'>双</button>
						<span>1.74</span>
					</div>
					<div class='col-xs-6'>
						<button class='btn3'>双</button>
						<span>1.74</span>
					</div>
					<input id="gyhz" />
				</div> -->
				
				<!-- 下注区 -->
			</div>
		</div>
		<div class="zdsd hidden" style='position: fixed;top:0;left:0;width: 100%;height: 100%;z-index: 60;background:rgba(0,0,0,0.5) ;'>
		</div>
		<div class="zdsd hidden set" style='position: fixed;left:0;z-index: 100;color: gray;padding: 15px;text-align: left;background: white;height: 227px;width: 80%;margin:10% ;bottom: 50px;border-radius:20px;border: 1px solid gray; '>
			<ul style="width: 100%;">
				<li class="hemei" style="text-align: center;padding:0 10px 10px;">
					<strong style="font-size: 20px;color: black;">合 买 设 置</strong>
				</li>
				<li class="hemei" style="line-height: 25px;">
					<span>我要分为：<input class="fs" style="width: 40px;border:1px white solid;border-bottom:1px solid gray;" value="0" /> 份　<span style="color: red;font-size: 10px;">每份￥<span class="meifen" style="color: red;font-size: 10px;">0.00</span>元</span></span><br>
					<span>我要提成：税后盈利的 <select><option class="tc">0%</option><option>1%</option><option>2%</option><option>3%</option><option>4%</option><option>5%</option><option>6%</option><option>7%</option><option>8%</option></select></span><br>
					<span>我要认购：<input class="rg" style="width: 40px;border:1px white solid;border-bottom:1px solid gray;" value="0" /> 份　<span style="color: red;font-size: 10px;">￥<span class="rengou" style="color: red;font-size: 10px;">0</span>元</span></span><br>
					<span>我要保底：<input class="bd" style="width: 40px;border:1px white solid;border-bottom:1px solid gray;" value="0"/> 份　<span style="color: red;font-size: 10px;">￥<span class="baodi" style="color: red;font-size: 10px;">0</span>元</span></span><br><br>
				</li>
				
				<li style="text-align: center;line-height: 40px;border-top: 1px solid gray;">
					<a class="col-xs-6" style="border-right: 1px solid gray;" onclick="cancel()">取 消</a>
					<a class="col-xs-6" style="color: blue;" onclick="submit()" >确 定</a>
				</li>
			</ul>
		</div>
		<br>　<br>　
		<div id="foot" class="col-xs-12 col-sm-4 col-sm-offset-4 text-center" style="position: fixed;bottom: 0px;border-top:2px solid silver ;padding:5px 10px;left: 0;height: 53px;background: white;">
			<div class="col-xs-4" style="padding: 0;text-align: left;">
				<div class="font10">已选 <span id="zhushu">0</span> 注，单注金额</div>
				<div style="position: fixed;"><input id="dzje" style="width:108px;border-radius: 5px;padding-left: 10px;border: 1px solid silver ;" value="${user.betacount }" /></div>
			</div>
			<div class="col-xs-3" style="padding: 0;padding-top: 7px;">
				<input type="checkbox" id="checkboxhm" /><span class="font18"> 合买</span>
			</div>
			<div class="col-xs-5" style="padding: 0;line-height: 37px;">
				<a onclick="clear1()" class="btn btn-sm" style="background: #eb6066;color:white;border:1px solid #eb6066;margin-right: 10px;">清空</a>
				<a onclick="comit()" class="btn btn-sm queren" style="border:1px solid black;">确定</a>
			</div>
		</div>
	</body>
	<script type="text/javascript">
	
	
	window.setInterval(function() {
		var x = Number($("#test1").css("margin-left").replace("px", ""));
		if (x < -3900) {
			$("#test1").css("margin-left", "300px");
		} else {
			$("#test1").css("margin-left", (x - 1) + "px");
		}
	}, 20)
		function clear1() {
			$(".act").removeClass("act");
			$(".wfdiv input").val("");
		}
		function submit(){
			if($(".hemei").attr("class").indexOf("hidden")==-1){
				var zcount=$(".fs").val();
				var price=$(".meifen").text();
				var profit=$(".tc").val();
				var rcount=$(".rg").val();
				var bcount=$(".bd").val();
				ajax({
					url:'<%=basePath %>order/submit.do',
					type:'post',
					data:{rebate:$("#fanli").text(),acount:$("#heji").text(),id:$("#orderid").text(),lottermoney:$("#danzhu").val(),zcount:zcount,price:price,profit:profit,rcount:rcount,bcount:bcount,state:0},
					success:function(data){
						var json = eval('(' + data + ')');
						if(json.data==1){
							$(".queren").text("下注成功");
							$(".zdsd").addClass("hidden");
							clear1();
						}
					}
				});
				
			}else{
				ajax({
					url:'<%=basePath %>order/submit.do',
					type:'post',
					data:{rebate:$("#fanli").text(),acount:$("#heji").text(),id:$("#orderid").text(),lottermoney:$("#danzhu").val()},
					success:function(data){
						var json = eval('(' + data + ')');
						if(json.data==1){
							$(".queren").text("下注成功");
							$(".zdsd").addClass("hidden");
							clear1();
						}
					}
				});
			}
		}
		
		/* $("#dzje").val($(".temp").length) */
		function comit() {
			var ajaxData = {
				url: '<%=basePath %>order/awards.do',
				type: "post",
				data: {
					lotterid: $("#id").text(),
					cname: $("#cname").text(),
					cname1: $("#cname1").text(),
					cname1: $("#dzje").val(),
					period: Number($(".period").text())+1,
					betacount:$("#dzje").val()
				},
				success: function(data) {
					$(".zdsd").removeClass("hidden");
					/* var json = eval('(' + data + ')');
					var mess = json.message;
					if(json.state==1){
						if(mess=='fail'){
							alert(json.data);
						}else{
							if(json.data[0]==0){alertme("号码选择有误，请参考购彩助手")}else{
								$("#maxpl").text(mess);
								$("#zhusu").text(json.data[0]);
								$("#orderid").text(json.data[1]);
								MAX_PL=mess;
								jisuan();
								$(".zdsd").removeClass("hidden");
							}
						}
					}else{
						alert("发生未知错误");
					} */
				}
			}		
			//$("#dzje").val($(".temp").length)
			for (var i = 0; i < $(".temp").length; i++) {
				/* var elementName = "#temp" + index */
				var item = ($(".temp").eq(i).val() != undefined) ? $(".temp").eq(i).val() : ''
				var paramName = "str" + String(i + 1)
				ajaxData.data[paramName] = item
			}
			ajax(ajaxData);
		}
		
		function comit1() {
			var ajaxData = {
				url: '<%=basePath %>order/awards1.do',
				type: "post",
				data: {
					lotterid: $("#id").text(),
					cname: $("#cname").text(),
					cname1: $("#cname1").text(),
					period: Number($(".period").text())+1,
				},
				success: function(data) {
					var json=eval('('+data+')');
					$("#zhushu").text(json.data)
				}
			}		
			//$("#dzje").val($(".temp").length)
			for (var i = 0; i < $(".temp").length; i++) {
				/* var elementName = "#temp" + index */
				var item = ($(".temp").eq(i).val() != undefined) ? $(".temp").eq(i).val() : ''
				var paramName = "str" + String(i + 1)
				ajaxData.data[paramName] = item
			}
			ajax(ajaxData);
		}
		function help(url, str) {
			document.write("<form action=<%=basePath %>help.do method=post name=form1 style='display:none'>");
			document.write("<input type=hidden name=url value='" + url + "'/>");
			document.write("<input type=hidden name=str value='" + str + "'/>");
			document.write("</form>");
			document.form1.submit();
		}
		$(function(){
			var allHeight = document.documentElement.clientHeight
			var headerHeight = 112
			var bottomDivHeight = document.querySelector("#foot").clientHeight
			var restHeight = allHeight - headerHeight - bottomDivHeight
			var mainDiv = document.querySelector(".class-div-mainDiv")
			mainDiv.style.height = String(restHeight) + "px"
			
			$(".user").click(function(){
				if($(".nav").attr("class").indexOf("hidden")!=-1){
					$(".nav").removeClass("hidden");
				}else{
					$(".nav").addClass("hidden");
				}
			});
			
			$(".wfbtn").click(function(){
				xz($("#id").text(),$("#cname").text(),$(this).attr("class").replace("wfbtn ",""))
			});
			$(".wf a").click(function(){
				$(".acti").removeClass("acti")
				$(this).addClass("acti")
			});
			$("#range,#danzhu").bind('input propertychange', function() {
				jisuan();
		    });
			
			
			$(".hemei .fs").blur(function() {
				var reg = /^[1-9]\d*$/;
				var heji1=$("#heji").text();
				var jieguo=heji1/Number($(".fs").val());
				if(!reg.test(Number($(".fs").val().trim()))){
					$(".fs").val("1");
				}else if(heji1/Number($(".fs").val())=="Infinity"){
					$(".fs").val("1");
				}else if(jieguo<1){
					$(".fs").val("1");
				}else{
					if(jieguo.toString().indexOf(".")!=-1&&jieguo.toString().split(".")[1].length>3){
						jieguo=jieguo.toString().split(".")[0]+"."+(Number(jieguo.toString().split(".")[1].substr(0,3))+1);
					}
					$(".meifen").text(jieguo);
					$(".rengou").text(accMul(Number($(".rg").val()),Number($(".meifen").text())));
					$(".baodi").text(accMul(Number($(".bd").val()),Number($(".meifen").text())));
				}
			});
			$(".hemei .rg").blur(function() {
				var reg = /^[1-9]\d*$/;
				if(!reg.test(Number($(".rg").val().trim()))){
					$(".rg").val("1");
				}else{
					$(".rengou").text(accMul(Number($(".rg").val()),Number($(".meifen").text())));
				}
			});
			$(".hemei .bd").blur(function() {
				var reg = /^[0-9]\d*$/;
				if(!reg.test(Number($(".bd").val().trim()))){
					$(".bd").val("0")
				}else{
					$(".baodi").text(accMul(Number($(".bd").val()),Number($(".meifen").text())));
				}
			});
			
			$("#checkboxhm").click(function(){
				if($(".zdsd").attr("class").indexOf("hidden")!=-1){
					$(".zdsd").removeClass("hidden");
				}else{
					;$(".zdsd").addClass("hidden");
				}
			});
			qiu();
		});
		/* $(".btn2,.btn3").click(function(){ */
		$(".xiazhu .col-xs-6,.xiazhu .myfl").click(function(){
			$(".queren").text("确定");
			if($(this).attr("class").indexOf("act")!=-1){
				$(this).removeClass("act");
			}else{
				if($("#cplay").text().indexOf("dt")!=-1){
					var q=$(this).attr("class").replace("btn2 ","");
					$("."+q).removeClass("act");
					$("#temp1").val($("#temp1").val().replace(q+",",""))
					$("#temp2").val($("#temp2").val().replace(q+",",""))
				}
				$(this).addClass("act");
			}
			$a=$(this).find("button");
			if($a.length==1){
				$a=$(this).parent().find("div");
				$input=$(this).siblings("input");
				$input.val("");
				for(var i=0;i<$a.length;i++){
					/* if($("#cplay").text().indexOf('bz')!=-1||$("#cplay").text().indexOf('3thtx')!=-1||$("#cplay").text().indexOf('3lhtx')!=-1){
						if($(".act").text()==''){
							$("#temp1").val("");
						}else{
							$("#temp1").val($(".act").text()+",");
						}
					}else */ 
					if($a.eq(i).attr("class").indexOf("act")!=-1){
						$input.val($input.val()+$a.eq(i).find("button").text()+",");
					}
				}
			}else{
				$input=$(this).parent().siblings("input");
				$input.val("");
				for(var i=0;i<$a.length;i++){
					if($a.eq(i).attr("class").indexOf("act")!=-1){
						$input.val($input.val()+$a.eq(i).text()+",");
					}
				}
			}
			comit1();
		});
		var dd=window.setInterval(function(){
			var time1 = new Date().format("hh:mm:ss").split(":");//当前时间
			time1=Number(time1[0]*60*60)+Number(time1[1]*60)+Number(time1[2]);
			var time=$(".lasttime").text().split(" ")[1].split(":");//上期开奖 
			time=Number(time[0]*60*60)+Number(time[1]*60)+Number(time[2]);
			time=time+Number($(".timespace").text())-time1;
			time--;
			var hour=Math.floor(time/3600);
			var minute=Math.floor((time-hour*3600)/60);
			var second=time-hour*3600-minute*60;
			if(time<30){
				$("#fenpan").removeClass("hidden");
			}
			if(time<0){
				$("#djs").text("正在开奖…");
				getnewdata();
			}else{
				$("#djs").text(bu0(hour)+":"+bu0(minute)+":"+bu0(second));
			}
		},1000);
		
		$("body").append("<div id='fenpan' class='hidden' style='position: fixed;bottom:0px;width:100%;background:rgba(200,200,200,0.8);height:55px;line-height:55px;font-size:30px;text-align:center;color:white;'>已封盘</div>");
		
		
		function qiu(){
			var lotternumber=$(".lotternumber").text().split(",");
			var lotter="";
			for(var i=0;i<lotternumber.length-1;i++){
				var x = Number(lotternumber[i]);
				if($("#cname").text().indexOf("ssc")!=-1||$("#cname").text().indexOf("11x5")!=-1||$("#cname").text().indexOf("k3")!=-1){
					lotter+="<div style='margin-right:3px;color:white;width:20px;height:20px;line-height:20px;font-size:12px;' class='fl text-center yuan qiu8'>"+lotternumber[i]+"</div>";
				}else if($("#cname").text().indexOf("pk10")!=-1){
					lotter+="<div style='margin-right:3px;color:white;width:20px;height:20px;line-height:20px;font-size:12px;' class='fl text-center yuan qiu"+x+"'>"+lotternumber[i]+"</div>";
				}
			}
			var lotternumber1=$(".lotternumber1").text().split(",");
			$(".lotternumber").html(lotter);
		}
		
		function getnewdata(){
			ajax({
				url:'getnewdata.do',
				type:'post',
				data:{key:$("#cname").text()},
				success:function(data){
					var json=eval('('+data+')');
					if($(".xiaqi").text()==json.data.period){
						$(".lotternumber").text(json.data.lotternumber);
						$(".xiaqi").text(Number(json.data.period)+1);
						$(".period").text(json.data.period);
						$(".lasttime").text(json.data.lottertime);
						qiu();
						$("#fenpan").addClass("hidden");
					}/* else{console.log($(".xiaqi").text()+" @"+json.data.period)} */
				},
				error:function(){
					alert("发生未知错误");
				}
			});
		}

		window.onload=function () {
			
		    document.addEventListener('touchstart',function (event) {
		        if(event.touches.length>1){
		            event.preventDefault();
		        }
		    })
		    var lastTouchEnd=0;
		    document.addEventListener('touchend',function (event) {
		        var now=(new Date()).getTime();
		        if(now-lastTouchEnd<=300){
		            event.preventDefault();
		        }
		        lastTouchEnd=now;
		    },false)
		}	
	</script>
</html>
